﻿$(document).ready(function () {
    $(document).on("click", ".game .checkButton .pickButton", function () {
        var gameID = $(this).attr("data-game-id");
        var teamID = $(this).attr("data-team-id");
        var userID = $(this).attr("data-user-id");


        var button = $(this);
        if (gameID == null) {
            window.location.href = "login.aspx";
        }
        else {
            $.ajax({
                type: "POST",
                url: "DisplayWeek.aspx/makePick",
                data: JSON.stringify({ gameID: gameID, teamID: teamID, userID: userID }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function () {
                    button.parent().parent().find(".picked:first").removeClass().addClass("pickButton");
                    button.removeClass().addClass("picked");
                }

            });
        }
    });
});